<?php

namespace App\Models;

use App\Models\BaseModel;

/**
 * 权限模型
 */
class Permission extends BaseModel
{
    protected $table = 'permissions';

    /**
     * 获取表字段
     *
     * @return array
     */
    protected function columns(): array
    {
        return [
            'id',
            'name',
            'slug',
            'module',
            'description',
            'created_at',
            'updated_at',
            'deleted_at',
        ];
    }

    /**
     * 获取权限名称
     * @param string $slug
     * @return string
     */
    public static function getPermissionName(string $slug): string
    {
        $map = [
            'list' => '列表',
            'view' => '详情',
            'create' => '创建',
            'update' => '更新',
            'delete' => '删除',
        ];
        return $map[$slug] ?? $slug;
    }
}